clear all

* Purpose: this file creates binned scatter plots of our main cross sectional regressions

*****************************************************************************
****************Step 1: Set the local name with your name ********************
*****************************************************************************
local name = "juan"


* set your path under your name
if "`name'" == "juan" {
cd "/Users/juanherreno/Dropbox/Investigacion/StateLevelCPIs/stata"
}

if  "`name'" == "emi" {
cd "e:/mydocs/dropbox/StateLevelCPIs/stata"
}

if  "`name'" == "joe" {
cd "/Users/jhazell/Dropbox (personal)/StateLevelCPIs/Stata"
}

if  "`name'" == "jon" {
cd ""
}


if "`name'" == "juan_pc" {
cd "C:/Users/jdh2181/Dropbox/Investigacion/StateLevelCPIs/stata/"
}


*****************************************************************************
*****************************************************************************

use "Code/code_to_share/data_reg.dta", clear



*****************************************************************************
*****************************************************************************
*****************************************************************************
*********************Step 3: Set the slack variable******** *****************
*****************************************************************************


gen u_reg = l4.mean_une
gen rp_reg = rp



*****************************************************************************
****************Create binscatters ********************
*****************************************************************************
set graphics off


gen dummy = year <= 1990

forvalues i = 0/1 {

binscatter infl_reg u_reg if dummy == `i', controls(i.statecode rp_reg) noaddmean savedata("working/binscatter_no_tfe_`i'") replace

}

forvalues i = 0/1 {

binscatter infl_reg u_reg if dummy == `i', controls(i.statecode i.date rp_reg) noaddmean savedata("working/binscatter_yes_tfe_`i'") replace

}




foreach i of numlist 0/1 {
	import delimited "working/binscatter_no_tfe_`i'", clear
	generate old = `i'
	generate time_fe = 0
	save "working/binscatter_no_tfe_`i'.dta", replace
}

foreach i of numlist 0/1 {
	import delimited "working/binscatter_yes_tfe_`i'.csv", clear
	generate old = `i'
	generate time_fe = 1
	save "working/binscatter_yes_tfe_`i'.dta", replace
}



*** Slide versions


use "working/binscatter_no_tfe_0", clear
append using "working/binscatter_no_tfe_1"
append using "working/binscatter_yes_tfe_0"
append using "working/binscatter_yes_tfe_1"

set graphics on

* Scatter without time effects
graph twoway (lfit infl_reg u_reg if old == 1 & time_fe == 0, lcolor(red) lwidth(0.8) range(-4 4)) ///
	(lfit infl_reg u_reg if old == 0 & time_fe == 0, lcolor(blue) lwidth(0.8) range(-4 4)) ///
	(scatter infl_reg u_reg if old == 1 & time_fe == 0, mcolor(red%15) msymbol(circle) msize(medlarge)) ///
	(scatter infl_reg u_reg if old == 0 & time_fe == 0, mcolor(blue%15) msymbol(triangle) msize(medlarge)) ///
	, ///
	xtitle("State Unemployment (pp)", size(huge)) subtitle("State Non-Tradeable Inflation (%)", position(11) ring(1) span size(huge)) ytitle("") ///
	plotregion(style(none)) graphregion(style(none)) ///
	ylabel(, nogrid labsize(huge)) yline(0, lcolor(gray%30)) xline(0, lcolor(gray%30)) ///
	legend(off) ///
	yscale(range(-2 2)) xscale(range(-4 4)) ylabel(-2 -1 0 1 2) xlabel(, labsize(huge))
graph save "Graphs/scatter_no_time_effect", replace
graph export "Graphs/scatter_no_time_effect.pdf", replace


* Scatter with time effects
graph twoway (lfit infl_reg u_reg if old == 1 & time_fe == 1, lcolor(red) lwidth(0.8) range(-4 4)) ///
	(lfit infl_reg u_reg if old == 0 & time_fe == 1, lcolor(blue) lwidth(0.8) range(-4 4)) ///
	(scatter infl_reg u_reg if old == 1 & time_fe == 1, mcolor(red%15) msymbol(circle) msize(medlarge)) ///
	(scatter infl_reg u_reg if old == 0 & time_fe == 1, mcolor(blue%15) msymbol(triangle) msize(medlarge)) ///
	, ///
	xtitle("State Unemployment (pp)", size(huge)) subtitle("State Non-Tradeable Inflation (%)", position(11) ring(1) span size(huge)) ytitle("") ///
	plotregion(style(none)) graphregion(style(none)) ///
	ylabel(, nogrid labsize(huge)) yline(0, lcolor(gray%30)) xline(0, lcolor(gray%30)) ///
	legend(off) ///
	yscale(range(-2 2)) xscale(range(-4 4)) ylabel(-2 -1 0 1 2) xlabel(, labsize(huge))
graph save "Graphs/scatter_time_effect", replace
graph export "Graphs/scatter_time_effect.pdf", replace
